"""Utility functions for metrics and timing."""
import time
import pickle
from contextlib import contextmanager

@contextmanager
def timing() :
    start = time.perf_counter()
    yield lambda: time.perf_counter() - start


def size_of_obj(obj) -> int:
    return len(pickle.dumps(obj))
